package com.CMC.yhdeng;

import java.io.IOException;
import java.util.ArrayList;

import android.util.JsonReader;
import android.util.JsonToken;

public class BookContent extends UnitBase
{
@Override
	public String toString() {
		
		return title;
	}

public ArrayList<ChapterContent> objs;
private int current=0;
public ChapterContent getCurrentChapter() {
	return objs.get(current);
}

public int getCurrent(){
	return current;
}
public void setCurrent(int currentChapter) {
	this.current = currentChapter;
}


public BookContent() {
	super();
	objs=new ArrayList<ChapterContent>();
}


public void add(ChapterContent ch){
	objs.add(ch);
	}

public void read(JsonReader reader)throws IOException
{
	reader.beginObject();
	readBaseMember(reader, "book_id", "book_title");
	String tag=reader.nextName();
		if (tag.compareTo("books_content") == 0) {
			JsonToken tok = reader.peek();
			if (tok != JsonToken.NULL) {
				reader.beginArray();
				while (reader.hasNext()) {
					ChapterContent cc = new ChapterContent();
					cc.read(reader);
					objs.add(cc);
				}

				reader.endArray();
			}else reader.nextNull();
		}
	reader.endObject();
}
}
